var artInfo = new Vue({
    el: "#article",
    data: {
        infoUrl: "api/sys/info/articleInfo?id=",
        sideUrl: "api/sys/info/getSideEdge",
        menuUrl: "api/sys/index/menuCol",
        menuData:{},
        article: {},
        sideDate:{},
        id: ""
    },
    mounted: function () {
        this.setPageType();//获取当前链接类型
        this.getInfoContent();
    },
    updated: function () {//数据加载完触 发
        $(".articleContent img").addClass("img-responsive");
        menu_hover();
    },
    methods: {
        setPageType: function () {
            this.id = this.getQueryString('id');
        },
        getQueryString: function (name) {//获取链接 参数
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        },
        getInfoContent: function () {
            this.$http.get(baseUrl + this.infoUrl + this.id).then(
                function (res) {
                    this.article = res.data.data;
                    $("title").html(this.article.tkdTitle);
                    $("meta[name='keywords']").attr("content",this.article.tkdKeywords);
                    $("meta[name='description']").attr("content",this.article.tkdDesc);
                }
            ).catch(function (response) {
                console.log(response)
            })
            this.$http.get(baseUrl + this.menuUrl).then(
                function (res) {
                    this.menuData = res.data.data;
                }
            ).catch(function (response) {
                console.log(response)
            })

            this.$http.get(baseUrl + this.sideUrl).then(
                function (res) {
                    this.sideDate = res.data.data;
                }
            ).catch(function (response) {
                console.log(response)
            })
        }
    },
    filters: {
        formatDate: function (val) {
            var value = new Date(val);
            var year = value.getFullYear();
            var month = padDate(value.getMonth() + 1);
            var day = padDate(value.getDate());
            /* var hour = padDate(value.getHours());
             var minutes = padDate(value.getMinutes());
             var seconds = padDate(value.getSeconds());*/
            return year + '/' + month + '/' + day;
        }
    }
})